import { RequestParams, ContentType, Method } from 'axios-mapper';
import qs from 'qs';
import https from '@/utils/https';
import { RootObject } from '@/model/rootObject';
import { Users } from '@/model/userModel';

const BASEURL = '/userApi';

export const loginRequest = (userInfo: RequestParams): any => {
  return https(false).request(`${BASEURL}/login?${qs.stringify(userInfo)}`, Method.POST, undefined, ContentType.form);
};

export const logoutRequest = (): any => {
  return https().request(`${BASEURL}/logout`, Method.POST, undefined, ContentType.json);
};

export const getUsers = (userInfo: RequestParams): any => {
  return https().request<RootObject<Users>>('user/userInfo', Method.POST, userInfo, ContentType.form);
};
